<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>留言界面</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="/static/css/layui.css">
	<link rel="stylesheet" href="/static/css/mian.css">
</head>
<body class="lay-blog">
{{ template "common/head.html" . }}
		<div class="container-wrap">
			<div class="container container-message">
				<div class="contar-wrap" id="contar-wrap">
					<form class="layui-form" action="">
						<div class="layui-form-item layui-form-text">
							<textarea name="content" class="layui-textarea" id="LAY-msg-content" style="resize:none"></textarea>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<button class="layui-btn" lay-submit lay-filter="commit">提交</button>
							</div>
						</div>
					</form>
					<div id="LAY-msg-box">
						<div class="info-box">
						{{ if eq .num  0 }}
							<div class="info-item">
								<p class="info-intr">暂时没有留言哦</p>
							</div>
							{{ else }}
							{{ range .messages }}
							<div class="info-item">
								<img class="info-img" src="/static/images/info-img.png" alt="">
								<div class="info-text">
									<p class="title count">
										<span class="name">{{ .User.Name }}</span>
										<span class="info-img like"><i class="layui-icon layui-icon-praise"></i>5.8万</span>
									</p>
									<p class="info-intr">{{ .Content }}</p>
								</div>
							</div>
							{{ end  }}
						{{ end }}
						</div>
					</div>
					<div id="test1" class="paging"></div>
					<div class="item-btn">
						{{ if gt .page 1 }}
						<button class="layui-btn" onclick="window.location.href='Message?pageno={{ add .page -1}}'">上一页</button>
						{{ end }}
						{{ if lt .page .allpage}}
						<button class="layui-btn" onclick="window.location.href='Message?pageno={{ add .page  1}}'">下一页</button>
						{{ end }}
					</div>
				</div>
			</div>
		</div>
  {{ template "common/footer.html" . }}
	<script src="/static/js/blog.js"></script>
	<script src="/static/layui/layui.js"></script>
	<script>
	layui.use(['form','jquery','laypage'], function(){
		var laypage = layui.laypage;
		var form = layui.form,
				$=layui.$;
		form.render();
		//监听提交
		form.on('submit(commit)', function(rdata){
			$.post("/Auth/Message",rdata.field,function (data){
				if (data.code===0){
					layer.msg("留言成功");
					if(data.action){
						setTimeout(function (){
							window.location.href=data.action
						},300)
					}
				}else{
					layer.msg("留言失败");
				}
			},"json").error(function (){
				layer.msg("网络异常");
			})
			return false;
		})
	})
	</script>
</body>
